package mo.tags.stack;

public class L1653 {

    public int minimumDeletions(String s) {
        int ans = 0, b = 0;
        for (char c : s.toCharArray()) {
            if (c == 'b') {
                b++;
            } else if (b > 0) {
                ans++;
                b--;
            }
        }
        return ans;
    }

}
